package com.ruoyi.project.system.controller;


import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.system.domain.SysProductUser;
import com.ruoyi.project.system.service.ISysProductUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 产品价格Controller
 *
 * @author ruoyi
 * @date 2024-06-20
 */
@RestController
@RequestMapping("/system/productPrice")
public class SysProductUserController extends BaseController
{
    @Autowired
    private ISysProductUserService sysProductUserService;

    /**
     * 查询产品价格列表
     */
    @PreAuthorize("@ss.hasPermi('system:user:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysProductUser sysProductUser)
    {
        startPage();
        List<SysProductUser> list = sysProductUserService.selectSysProductUserList(sysProductUser);
        return getDataTable(list);
    }

    /**
     * 导出产品价格列表
     */
    @PreAuthorize("@ss.hasPermi('system:user:export')")
    @Log(title = "产品价格", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysProductUser sysProductUser)
    {
        List<SysProductUser> list = sysProductUserService.selectSysProductUserList(sysProductUser);
        ExcelUtil<SysProductUser> util = new ExcelUtil<SysProductUser>(SysProductUser.class);
        util.exportExcel(response, list, "产品价格数据");
    }

    /**
     * 获取产品价格详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:user:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysProductUserService.selectSysProductUserById(id));
    }

    /**
     * 新增产品价格
     */
    @PreAuthorize("@ss.hasPermi('system:user:add')")
    @Log(title = "产品价格", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysProductUser sysProductUser)
    {
        return toAjax(sysProductUserService.insertSysProductUser(sysProductUser));
    }

    /**
     * 修改产品价格
     */
    @PreAuthorize("@ss.hasPermi('system:user:edit')")
    @Log(title = "产品价格", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysProductUser sysProductUser)
    {
        return toAjax(sysProductUserService.updateSysProductUser(sysProductUser));
    }

    /**
     * 删除产品价格
     */
    @PreAuthorize("@ss.hasPermi('system:user:remove')")
    @Log(title = "产品价格", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysProductUserService.deleteSysProductUserByIds(ids));
    }
}
